package com.yyh.synctool.client.job;

import com.yyh.synctool.client.component.TaskHelper;
import com.yyh.synctool.client.tool.TaskKey;
import org.quartz.JobBuilder;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobKey;

/**
 * Job工厂类
 * @author xuan
 * @date 2021/12/6
 */
public class JobFactory
{
    /** 测试任务 */
    public static JobDetail getTestJob(JobDataMap jobDataMap) {
        JobKey jobKey = TaskKey.getTestJobKey();
        JobDetail jobDetail = JobBuilder.newJob(TestJob.class)
                .withIdentity(jobKey)
                .usingJobData(jobDataMap)
                .build();

        return jobDetail;
    }

    /** 库存任务 */
    public static JobDetail getStockJob(JobDataMap jobDataMap) {
        JobKey jobKey = TaskKey.getStockJobKey();
        JobDetail jobDetail = JobBuilder.newJob(StockJob.class)
                .withIdentity(jobKey)
                .usingJobData(jobDataMap)
                .build();

        return jobDetail;
    }

    /** 价格任务 */
    public static JobDetail getPriceJob(JobDataMap jobDataMap) {
        JobKey jobKey = TaskKey.getPriceJobKey();
        JobDetail jobDetail = JobBuilder.newJob(PriceJob.class)
                .withIdentity(jobKey)
                .usingJobData(jobDataMap)
                .build();

        return jobDetail;
    }
}
